function RobotChooseGroupController(
    $rootScope,
    RobotGroup,
    params,
    API,
    Detail,
    $http,
    $uibModal,
    $scope,
    $state,
    $stateParams
){
    var vm=this;
    vm.isSelectting = false;
    vm.isshow = false;
    vm.queryParams = _.clone($stateParams);
    vm.resultMsg;
    vm.robotId = params;
    vm.scope = $rootScope.$new();

    //已选择添加机器人数组容器
    vm.selectedArray = [];

    //是否显示机器人添加按钮
    vm.isShowAddBtn = true;

    vm.cancel = function() {
        $state.go('robotList');
    }

    vm.chooseGroup = function($index){
        vm.isShowAddBtn = false;
        var keepGoing = false;

        if($index>=0){
            var groupId = vm.groups[$index].id;

            RobotGroup.addRobotInGroup({robotId: vm.robotId, groupId: groupId}).$promise.then(function(response){
                var result = response.result;
                if(result == 'success'){
                    $state.go('robotList');
                }else if(result == "err"){
                    vm.resultMsg = "添加失败,"+ response.msg +"！";
                    keepGoing = true;
                }else{
                    vm.resultMsg = "添加失败！请稍后再试！";
                    keepGoing = true;
                }
                if(keepGoing){
                    vm.scope.data = {
                        msg:vm.resultMsg
                    }
                    var tipsModel = $uibModal.open({
                        templateUrl: 'tipsModel.html',
                        controller: 'robotTipsCtrl',
                        scope:vm.scope
                    });
                }
                vm.isShowAddBtn = true;
            })
        }
    }


    vm.select = function (){
        vm.isSelectting = true;
        Detail.searchGroup({
            groupName:vm.queryParams.groupName,
        }).$promise.then(function(response){
            vm.groups = response.content;
            if(vm.groups == 0){
                vm.isshow = true;
            }else{
                vm.isshow = false;
            }
            vm.isSelectting = false;
        })
    };

    vm.select();
}